<? 
$current = $_GET['current'];
if (!isset($current)) $current = 0;
  
$query = getClankyCount();
$fetch = MySQL_Fetch_Array($query);

$rows = $fetch["POCET"];        //celkový počet článků v db
  
$paginator = new Paginator(15, 3, $current, $rows, PAGE_ADMIN_REPORTS, "");

?>
<div class="center">
	<a class="button preloader" href="<? echo redirect_str(PAGE_ADMIN_REPORT); ?>">PŘIDAT ČLÁNEK</a><br /><br />
</div>

<br />

<table class="centered small-table">
  <tr>
    <th>titulek</th>
    <th>vytvořeno / upraveno</th>
    <th>autor</th>
    <th>akce</th>
  </tr>
  
<?php

    $query = getClanky($paginator->getFirstPageIndex(), $paginator->getPageSubjects());
    $idx = 0;
    while($fetch = MySQL_Fetch_Array($query)){
      $id_clanku = $fetch["ID_CLANKU"];
      $datum_upravy = $fetch["CAS_UPRAVY"];
      $nadpis = $fetch["NADPIS"];
      $autor = getUsername($fetch["ID_AUTOR"]);
      
      if($idx % 2 == 0) { echo "<tr class='second'>"; }
      else echo "<tr>";
        echo "<td class='lefted'>".$nadpis."</td>";
        echo "<td>".$datum_upravy."</td>";
        echo "<td>".$autor."</td>";
        echo "<td>";
        if($fetch["ID_AUTOR"] == $user->getId() || $user->getRole() == ROLE_ADMIN) {
        	echo "<a class='preloader' href=\"".redirect_str(PAGE_ADMIN_REPORT).add_par("id_clanku=".$id_clanku)."\"'><img class='icon-btn' src='./img/icons/edit.png'></a>";
      		echo "<a class='preloader' href=\"".redirect_str(PAGE_ADMIN_REPORTS).action(ACTION_DELETE_REPORT).add_par("id_clanku=".$id_clanku)."\"><img class='icon-btn' src='./img/icons/delete.png'></a>";
    	}
    	echo "</td>";
      echo "</tr>";
      $idx ++;
    }
  ?>
    <tr class="footer">
      <td colspan="5"><? $paginator->show(); ?></td>
    </tr>
</table>
